import Vue from "vue";

Vue.filter("dateFormat", function (dateStr, time) {
    if (!dateStr) {
        return '';
    }
    //var date = new Date(dateStr);
    var date = new Date(Date.parse(dateStr.replace(/-/g, "/")));
    var year = date.getFullYear();
    var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1);
    var day = date.getDate() + 1 < 10 ? '0' + date.getDate() : date.getDate();
    var hh = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
    var mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
    var ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();

    if (time && time.toLowerCase() === 'yyyy-mm-dd') {
        return `${year}-${month}-${day}`;
    }
    else if (time && time.toLowerCase() === 'hh:mm:ss') {
        return `${hh}:${mm}:${ss}`;
    } else {
        return `${year}-${month}-${day} ${hh}:${mm}:${ss}`;
    }
});


Vue.filter("trainClassStatus",function(val){
  if(val==0){
    return '未发布';
  }
  else if(val==1){
    return '未开始';
  }else if(val==2){
    return '进行中';
  }else if(val==3){
    return '已结束';
  }
});
